package com.example.goods_admin.controller;

import com.example.goods_admin.common.Result;
import com.example.goods_admin.service.BookService;
import com.example.goods_admin.service.UploadFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/book")
public class BookController {
    @Autowired
    BookService bookService;

    @PostMapping("/uploadExcel")
    public Result uploadExcel(@RequestPart MultipartFile file) {
        return bookService.uploadExcel(file);
    }

    @GetMapping("/downloadExcel")
    public void downloadExcel(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
        bookService.downloadExcel(httpServletResponse);
    }
}
